﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;//Added by Tools
using System.Device.Location;//Add Ref,Using


namespace Day1
{
    public partial class WhereAmI : PhoneApplicationPage
    {
        public WhereAmI()
        {
            InitializeComponent();
        }
        GeoCoordinateWatcher gps;
        private void PhoneApplicationPage_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            gps = new GeoCoordinateWatcher();
            //gps.DesiredAccuracy = GeoPositionAccuracy.High;
            gps.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(gps_PositionChanged);
            gps.Start();
            myMap.ZoomLevel = myMap.ZoomLevel * 12;
            
        }

        void gps_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
        {
            if (gps.Status == GeoPositionStatus.Ready)
                myMap.Center = gps.Position.Location;
        }
    }
}
